/** 品牌数据操作函数 */
import {
  BRAND_ADD,
  BRAND_EDIT,
  BRAND_DEL
} from './brandType'

const initData = [
  { id: 2, name: "华为" },
  { id: 1, name: "小米" }
]

function brandReducer(state = initData, creator) {

  switch (creator.type) {

    case BRAND_ADD:
      console.log("增加品牌数据")
      break;

    case BRAND_EDIT:
      console.log("编辑品牌数据")
      break;

    case BRAND_DEL:
      console.log("删除品牌数据", creator.data)
      state = state.filter(item => item.id !== creator.data.id)
      return state

    default:
      console.log("读取品牌数据")
      return state
  }

}

export default brandReducer